//
//  WriteChangeTableViewCell.swift
//  Exchange
//
//  Created by 孟祥群 on 2018/5/4.
//  Copyright © 2018年 common. All rights reserved.
//

import UIKit

class WriteChangeTableViewCell: BaseTableViewCell {
    lazy var coinLabel: UILabel = {
        let label = BaseLabel(style: .twiceStyle)
        label.font = UIFont.systemFont(ofSize: 15)
//        label.text = "BTC"
        return label
    }()
    lazy var coninText: BaseTextField = {
        let textField = BaseTextField(changeView: nil, szBounds: CGRect.zero)
        textField.keyboardType = UIKeyboardType.decimalPad
        textField.font = UIFont.systemFont(ofSize: 15)
        textField.placeholder = kText("输入数量")
        textField.setPlaceholderColor()
        textField.themeTextColor  = ThemeManager.ThemeColorKeys.text1
        return textField
    }()
    
    lazy var changeBtn: UIButton = {
        let btn = UIButton()
        btn.setImage(UIImage(named: "assetexc"), for: UIControlState.normal)
        return btn
    }()
    
    lazy var breedLabel: UILabel = {
        let label = BaseLabel(style: .twiceStyle)
        label.font = UIFont.systemFont(ofSize: 15)
        label.text = AppCacheInfo.default.currency
        return label
    }()
    
    lazy var breedBtn: CustomBtn = {
        let btn = CustomBtn(style: .styleRight)
        btn.isHidden = true
        btn.isUserInteractionEnabled = false
//        btn.photoImageView.image = UIImage(named: "arrow_down")
        btn.nameLabel.font = UIFont.systemFont(ofSize: 15)
        return btn
    }()
    
    lazy var breedText: BaseTextField = {
        let textField = BaseTextField(changeView: nil, szBounds: CGRect.zero)
        textField.textAlignment = NSTextAlignment.right
        textField.font = UIFont.systemFont(ofSize: 15)
        textField.keyboardType = UIKeyboardType.decimalPad
        textField.themeTextColor  = ThemeManager.ThemeColorKeys.text1
        return textField
    }()
    
    lazy var titleLabel: UILabel = {
        let label = UILabel()
        label.textColor = kTitleColor
        label.font = UIFont.systemFont(ofSize: 12)
        label.text = kText("从")
        return label
    }()
    
    lazy var dtLabel: UILabel = {
        let label = UILabel()
        label.textColor = kTitleColor
        label.font = UIFont.systemFont(ofSize: 12)
        label.text = kText("到")
        return label
    }()
    
    override func setUpUI() {
        super.setUpUI()
        
        self.contentView.addSubview(coinLabel)
        coinLabel.snp.makeConstraints { (make) in
            make.left.equalToSuperview().offset(16)
            make.bottom.equalToSuperview().offset(-12)
            make.width.lessThanOrEqualTo(40)
        }
        
        self.contentView.addSubview(coninText)
        coninText.snp.makeConstraints { (make) in
            make.left.equalToSuperview().offset(55)
            make.bottom.equalToSuperview().offset(-12)
            make.right.equalToSuperview().offset(kSCREEN_WIDTH/2-20)
        }
        
        self.contentView.addSubview(changeBtn)
        changeBtn.snp.makeConstraints { (make) in
            make.centerY.equalTo(coinLabel)
            make.centerX.equalToSuperview()
            make.width.height.equalTo(40)
        }
        
        self.contentView.addSubview(breedLabel)
        breedLabel.snp.makeConstraints { (make) in
            make.right.equalToSuperview().offset(-15)
            make.bottom.equalToSuperview().offset(-12)
            make.width.lessThanOrEqualTo(40)
        }
        
        self.contentView.addSubview(breedText)
        breedText.snp.makeConstraints { (make) in
            make.right.equalToSuperview().offset(-50)
            make.bottom.equalToSuperview().offset(-12)
            make.left.equalToSuperview().offset(kSCREEN_WIDTH/2+20)
        }
        
        self.contentView.addSubview(breedBtn)
        breedBtn.snp.makeConstraints { (make) in
            make.right.equalToSuperview().offset(-15)
            make.bottom.equalToSuperview().offset(-12)
            make.width.equalTo(80)
        }
        breedBtn.photoImageView.snp.makeConstraints { (make) in
            make.right.equalToSuperview()
            make.centerY.equalToSuperview()
        }
        breedBtn.nameLabel.snp.makeConstraints { (make) in
            make.right.equalTo(breedBtn.photoImageView.snp.left).offset(-5)
            make.bottom.equalToSuperview()
        }
        
    }
    override func setModel(model: BaseModel) {
        let newModel = model as? AssetModel
        coinLabel.text = newModel?.coinCode
        
    }
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }

}
